//
//  DemoArraySort.m
//  ocdemo
//
//  Created by JIENING ZHANG on 2019/4/5.
//  Copyright © 2019 JIENING ZHANG. All rights reserved.
//

#import "DemoArraySort.h"

@implementation DemoArraySort
+ (void)demoLogic {
    NSArray *month = @[
                       @"January",
                       @"February",
                       @"March",
                       @"April",
                       @"May",
                       @"June",
                       @"July",
                       @"August",
                       @"September",
                       @"October",
                       @"November",
                       @"December",
                       ];
    
    NSArray *monthSorted = [month sortedArrayUsingComparator:^NSComparisonResult(id  _Nonnull obj1, id  _Nonnull obj2) {
        NSComparisonResult res = [((NSString *)obj1) compare:((NSString *)obj2)];
        if(res == NSOrderedAscending) {
            return NSOrderedDescending;
        } else {
            return NSOrderedAscending;
        }
    }];
    
    NSUInteger index=0;
    for(NSString *str in month) {
        NSLog(@"DemoArraySort, month, %ld, %@", index, str);
        ++index;
    }
    
    index=0;
    for(NSString *str in monthSorted) {
        NSLog(@"DemoArraySort, monthSorted, %ld, %@", index, str);
        ++index;
    }
}
@end
